using System;
using System.Web.UI.WebControls;
using Framework.Library.Base.Base;

namespace Framework.Portal.Layouts.Admin.Components.Database
{
    public partial class Views : BaseControl
    {
        //_View objView = new _View();
        protected void Page_Load(object sender, EventArgs e)
        {
            //if ((!CurrentUser.IsSuperAdmin && CommandController.IsSystemModule(AdminPage.CurrentCommand.CommandID)) || !CommandController.IsAvailableForUser(AdminPage.CurrentCommand.CommandID, CurrentUser.UserID, Convert.ToInt32(cfg.Portal)))
            //    Response.Redirect(cfg.ADMIN_CMD, true);
            //if (!Page.IsPostBack)
            //{                
            //    lblCommandName.Text = MENUNAME;
            //    LoadData();
            //}
        }

        //private void LoadData()
        //{
        //    dtgInfos.DataSource = objView.GetViews();
        //    dtgInfos.ItemDataBound +=new RepeaterItemEventHandler(dtgInfos_ItemDataBound);
        //    dtgInfos.DataBind();
        //}

        protected void dtgInfos_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //DataRowView rowView = (DataRowView)e.Item.DataItem;
            //HtmlInputCheckBox myCheckDrop = (HtmlInputCheckBox)e.Item.FindControl("checkDrop");
            //if (myCheckDrop != null)
            //{
            //    myCheckDrop.Value = rowView["id"].ToString();
            //}
        }

        protected void dtgInfos_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            //string id = e.CommandArgument.ToString();
            //switch (e.CommandName)
            //{
            //    case "Property":
            //        Response.Redirect(MiscUtility.AdminUrlParams(CommandController.GetCommandbyID((int)PortalControls.ViewProperty)) + "&id=" + id);
            //        break;
            //    case "Drop":
            //        Response.Redirect(MiscUtility.AdminUrlParams(CommandController.GetCommandbyID((int)PortalControls.ViewAction)) + "&id=" + id + "&action=drop");
            //        break;                
            //    default:
            //        break;
            //}
        }

        protected void btnCreateView_Click(object sender, EventArgs e)
        {
            //Response.Redirect(MiscUtility.AdminUrlParams(CommandController.GetCommandbyID((int)PortalControls.ViewNew)));
        }

        protected void btnDrop_Click(object sender, EventArgs e)
        {
            //List<RepeaterItem> removed = new List<RepeaterItem>();
            //foreach (RepeaterItem items in dtgInfos.Items)
            //{
            //    removed.Add(items);
            //}
            //foreach (RepeaterItem it in removed)
            //{
            //    HtmlInputCheckBox deleteChkBxItem = (HtmlInputCheckBox)it.FindControl("checkDrop");
            //    if (deleteChkBxItem.Checked)
            //    {
            //        objView.ID = Convert.ToInt64(deleteChkBxItem.Value);
            //        objView.LoadProperties();
            //        try
            //        {
            //            objView.Drop();
            //        }
            //        catch (Exception ex)
            //        {
            //            Response.Write(ex.Message);
            //        }
            //    }
            //}
            //LoadData();
        }
    }
}